﻿using System;
using UnityEngine.Serialization;

namespace UnityEngine.Rendering.PostProcessing
{

    //[PostProcess(typeof(BloomRenderer), "Unity/Bloom")]

    [Serializable]
    [PostProcess(typeof(WaveRenderer),PostProcessEvent.AfterStack, "Unity/Wave")]
    public sealed class Wave : PostProcessEffectSettings
    {
        [Range(0f, 1f), Tooltip("Makes transitions between under/over-threshold gradual. 0 for a hard threshold, 1 for a soft threshold).")]
        public FloatParameter waveStrength = new FloatParameter { value = 0.0f };

        public override bool IsEnabledAndSupported(PostProcessRenderContext context)
        {
            return enabled.value
                && waveStrength.value > 0.01f
                && waveStrength.value < 0.90f;
        }
    }

    [UnityEngine.Scripting.Preserve]
    internal sealed class WaveRenderer : PostProcessEffectRenderer<Wave>
    {
        public override void Render(PostProcessRenderContext context)
        {
            //// 查找Shader文件
            var sheet = context.propertySheets.Get(context.resources.shaders.wave);
             //传递属性到Shader
            sheet.properties.SetFloat("_WaveStrength", settings.waveStrength);
            context.command.BlitFullscreenTriangle(context.source, context.destination, sheet, -1);

        }

        
    }
 }
